feat(scope_definition): read action list from service spec by default - #458
Conversation
…olve Dropping the hardcoded default means a caller that relied on it, and whose spec predates `available_actions`, now resolves to an empty list. That reaches the action_specification for_each as zero instances and destroys every action specification the scope has registered — with no error, since an empty list is not one. Measured on a live implementation: 44 destroys across four scopes, in a plan that reads as deliberate. The precondition sits on the service specification rather than on the action_specification resource because that resource has no instances when the for_each is empty, so its own preconditions never run. Callers passing action_spec_names explicitly are unaffected — verified against an implementation where one scope keeps its list in locals and its spec has no available_actions: the plan reports no changes.
|
Agregué un commit a este branch ( Sin el default, un caller que dependía de él resuelve a Medido en Un plan que se lee como intencional y deja al scope sin crear/borrar scopes, Dónde va el precondition. Lo puse en Retrocompatibilidad. Verifiqué los dos caminos contra una implementación:
Así que quien pasa la lista no se ve afectado. Quien dependía del default recibe un Por otro lado, para que este PR se pueda mergear sin romper a los scopes que hoy
Sugerencia de orden: los dos PRs de specs primero (son inocuos mientras el módulo |
|
Aporto el
y Cero creates, cero updates, cero destroys, para los cuatro scopes — 44 action Los dos casos de compatibilidad, probados por separado contra la misma
El segundo con este error, que es el comportamiento que buscábamos: Sobre el ordering: confirmo lo que dice la descripción — ni Dejo la rama de prueba en |
The list of actions a scope offers lived in the scope_definition module as a hardcoded default, far from the scope that implements them. That distance is what let them drift: the default listed "kill-instances" while the containers scope ships "kill-instance", and the mismatched name resolved to a 404 whose body reached jq as "404: Not Found" — a parse error that said nothing about a missing file. Declaring them here puts the list next to the action templates it names, so adding or renaming an action is one change in one repository. The fourteen match the action templates in specs/actions and the specifications currently registered for this scope. Requires the module to read the field: nullplatform/tofu-modules#458.
The list of actions a scope offers lived in the scope_definition module as a hardcoded default, far from the scope that implements them. Declaring it here puts the list next to the action templates it names. The seven match the templates in specs/actions and the specifications currently registered for this scope. Requires the module to read the field: nullplatform/tofu-modules#458.
Summary
action_spec_names's default becomesnull; when unset,scope_definitionnow falls back toavailable_actionsfrom the fetchedservice-spec.json.tpl(added in feat: add available_actions to service-spec templates scopes#208) instead of a hardcoded 15-item list tuned fork8s.data.tf's twofor_eachexpressions (data.http.action_templates,data.external.action_specs) now readlocal.static_action_specsinstead ofvar.action_spec_namesdirectly — required for the fallback to actually reach the resources that fetch/create action specs (an initial version of this change missed this and would have hard-failedtofu planfor any caller relying on the new default; caught in review and fixed).lifecycle.preconditiononnullplatform_service_specification.from_template(main.tf): ifaction_spec_namesis left unset AND the fetched spec doesn't haveavailable_actionsyet,tofu plannow fails loudly with a clear message instead of silently destroying every existingnullplatform_action_specificationfor that scope (an emptyfor_eachis a destroy, not an error — caught in final review).action_spec_namesexplicitly (scheduled_task, static-files, and the various account configs) is unaffected — the override still wins.Merge/release ordering — please read before merging
repository_service_spec_branchdefaults tomain. As of this PR,nullplatform/scopes'smainbranch does not haveavailable_actionsyet — nullplatform/scopes#208 targetsbeta, notmain, and hasn't merged. The precondition above means this is no longer a silent-outage risk (plan will fail with a clear error instead), but to actually get the intended behavior:beta, then let it flow tomain.available_actionsis present inmain's spec templates (e.g.git show origin/main:k8s/specs/service-spec.json.tpl | grep available_actions).action_spec_nameswill hit the new precondition error until step 1-2 land.Test plan
tofu fmt -check/tofu validatepassfor_each/null-default failure mode is fixed (without needing real credentials)tofu planagainst a live k8s scope (withscopesmainalready updated per the ordering note above) shows no changes (attach output before merge)Depends on nullplatform/scopes#208 (adds
available_actionsto the service specs this module reads) reachingmain, not just merging tobeta.